﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace web7
{
    public partial class _2016020719_4 : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                ViewState.Add("suer", "小小");
                ViewState.Add("vocation", "教师");
            }
            Label1.Text = "ViewState 信息如下：<br>姓名：";
            Label1.Text += ViewState["suer"];
            Label1.Text += "<br>职业：";
            Label1.Text += ViewState["vocation"];
        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            if (TextBox2.Text != "")
                ViewState["suer"] = TextBox1.Text;
            if (TextBox2.Text != "")
                ViewState["vocation"] = TextBox2.Text;
        }

        protected void Button2_Click(object sender, EventArgs e)
        {
            Label1.Text = "ViewState 信息如下：<br>姓名：";
            Label1.Text += ViewState["suer"];
            Label1.Text += "<br>职业：";
            Label1.Text += ViewState["vocation"];
        }
    }
}